package com.universally.example.app

import androidx.compose.runtime.Composable
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.compose.universally.BuilderComposableV
import com.universally.example.app.page.MainPage
import com.compose.universally.components.BaseMaterial
import com.compose.universally.components.BaseNavHost
import com.compose.universally.components.NavHostPageOptions
import com.universally.example.app.const.BaseTheme
import com.universally.example.app.page.TextPage

@Composable
fun MainApp() {
    val navController = rememberNavController()
    BaseMaterial(
        typography = BaseTheme.typography,
        darkColorScheme = BaseTheme.darkColorScheme,
        lightColorScheme = BaseTheme.lightColorScheme
    ) {
        BaseNavHost(startDestination = Route.Main.name, navController = navController) {
            Route.entries.map { route ->
                composable(route.name, content = {
                    val options =
                        NavHostPageOptions(controller = navController, backStackEntry = it)
                    route.builder(options)
                })
            }.toList()
        }
    }
}

enum class Route(val builder: BuilderComposableV<NavHostPageOptions>) {
    Main({ MainPage(it) }), Text({ TextPage(it) }), ;


    fun push() {

    }
}
